home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
pascal
/
co256_05.zip
/
COL256.DOC
next >
Wrap
Text File
|
1993-12-31
|
15KB
|
372 lines
COL256 description.
===================
What is COL256?
===============
COL256 is a unit developed for Borland Pascal 7.0 to have access to video
modes with 256 colors and a 'high' resolution (more than 320x200).
I decided to program it as a unit to be independent of Borlands GRAPH unit
and to get my own expieriences in graphics programming on a IBM-PC.
IMPORTANT
=========
It is just a prerelease to have it tested on several machines. Eventhough I
designed it carefully using standard VGA frequencies I could not guarantee
that it works properly on YOUR machine, YOUR card and YOUR monitor.
----\\ ESPECIALLY I WOULD TAKE *NO* RESPONSIBILITY //----
---======== >> FOR ANY DAMAGE TO YOUR HARDWARE OR ANYTHING << ========---
----// ELSE CAUSED BY USING THIS PACKAGE. \\----
If you have tested it on your machine and it worked well please send me a
short note containing information about your graphics card and monitor
(manufacturer, type,...). You might use the SPEED program and send me the
LOGFILE created by SPEED. !! PLEASE ONLY EMail !!
Features of COL256
==================
COL256 supports:
* graphic modes with a resolution of 320 or 360 pixels horizontally
and 200,240,400 or 480 pixels vertically in ANY combination on
almost EVERY (register compatible) VGA.
==> ^^^^^^ 'almost' because I would not guarantee that it runs on
==> YOUR VGA, but I checked it on a lot of cards and it worked
==> well.
* virtual screen programming
* Support of soft scrolling/panning of the vitrual screen
* fast assembly routines to achieve high graphics performance and
compact code
* several pages supported if enough memory would be availiable on a
256 Kbyte VGA (even for virtual screens).
* both DOS real mode and DOS protected mode
* palette manipulation without using BIOS (thus avoiding flicker on
screen, many BIOS'es don't care about this) so that you would be
able to implement fine palette animations.
* hardware bit manipulations as supported by a standard VGA
* free definable clipping window
* error reporting similar to Borlands GRAPH unit.
(Some errors will not occur, because features are not implemented
yet.)
Future Plans:
* Support of Borland's stroke fonts (.CHR), standard BIOS bitmap fonts
and free defined 'sprite' fonts.
* extended drawing routines (circles, ellipses, filling, etc)
* full support of bitmap routines
* support of higher resolutions of virtual screens using more than 256k
video memory
* GetErrorText function to make error reporting easier
* TP 6.0 support
* better debugging support
System requirements
===================
COL256 runs only on 286 or higher, so be sure to check if a 286 (or higher)
processor is present (eventhough I think a 8086 with a VGA running at high
resolution graphic modes would be a strange hardware combination).
During mode initialisation COL256 will check if a VGA is present, but I'm
NOT checking if it is register compatible.
How to use it
=============
As usual you would have to include COL256 in your 'uses' list at the
beginning of your program and include the directory where the TPU/TPP files
located in your unit path. Then use the graphic procedures as described
below.
COL256 types and variables
==========================
The used types for palette maipulation routines are declared as follows:
type TColor = record r,g,b:byte end;
TPalette = array[0..256] of TColor;
Thus TColor holds a RGB tripel, where r,g and b values are from 0..63
and TPalette holds 256 of those RGB tripel, describing the full palette.
Constants declared by COL256 are
* Mode-ID's for suported video modes:
M320x200 = 0; M320x240 = 1; M320x400 = 2; M320x480 = 3;
M360x200 = 4; M360x240 = 5; M360x400 = 6; M360x480 = 7;
NotMemClear = $8000; NoStateInit = $4000;
If bit 15 of <mode> is set, video memory will not be initialized
(filled with 00h) during mode initialization. If bit 14 of <mode> is
set, no state initialisation (grCursor,...) will be performed.
(See EnterGraphMode for detail.)
Note: y-resolution is given by bits 0 and 1,
x-resolution is given by bit 2
* Values for error reporting (same as from GRAPH):
grOk = 0; { No error }
grNoInitGraph = -1; { BGI graphics not installed }
grNotDetected = -2; { Graphics hardware not found }
grFileNotFound = -3; { Device driver file (.BGI) not found }
grInvalidDriver = -4; { Invalid device driver file }
grNoLoadMem = -5; { Not enough memory to load driver }
grNoScanMem = -6; { Out of memory in scanfill }
grNoFloodMem = -7; { Out of memory in flood fill }
grFontNotFound = -8; { Fontfile (.CHR) not found }
grNoFontMem = -9; { Not enough memory to load font }
grInvalidMode = -10; { Invalid graphics mode (not supported) }
grError = -11; { Graphics error (generic error) }
grIOerror = -12; { graphics I/O error (file access) }
grInvalidFont = -13; { Invalid font file }
grInvalidFontNum = -14; { Invalid font number }
* Write mode constants for SetWriteMode
NormalPut = 0; { 00000_b }
AndPut = 8; { 01000_b }
OrPut = 16; { 10000_b }
XorPut = 24; { 11000_b }
Note: Use this constants, first your code gets better readable and
second they are NOT the same as GRAPH's BitBlt constants.
* Initialized Variables:
const ActiveMode : integer = -1;
OldMode : integer = -1;
ActiveMode holds the mode-ID of the current mode. OldMode holds the
video mode (as BIOS told me) before the first EnterGraphMode call.
* Variables:
var xMin,xMax,
yMin,yMax,
ActivePage,VisualPage,
grCurX,grCurY : integer;
GetX : integer absolute grCurX;
GetY : integer absolute grCurY;
GetMaxX : integer absolute xMax;
GetMaxY : integer absolute yMax;
GetMinX : integer absolute xMax;
GetMinY : integer absolute yMax;
GetVisualPage : integer absolute VisualPage;
GetActivePage : integer absolute ActivePage;
As you can see I mapped variables with the same names as the
corresponding GRAPH functions at my internal stuff. This should be
faster than function calls to get actual graphics position etc.
But because I use them also for internal purposes do NEVER write
to these variables; use the provided functions/procedures to modify
them !
COL256 procedures and variables
===============================
procedure EnterGraphMode (Mode:word);
Initializes the mode given by the Mode value by resetting the hardware,
initializing internal tables/variables and clearing video memory if
required. (See constants for modes supported.)
If NoStateInit is set, the selected clipwindow, the selected pages and
the graphics cursor would not be initialized (with all consequences).
procedure ExitGraphMode;
Initializes the old mode set before the first EnterGraphMode call
using BIOS.
function GetModeName(mode:integer):string;
Returns a string describing the mode given by the mode ID, such as
'320x240, 256 colors' for mode=M320x240 and 'Invalid Mode' for mode=12.
procedure SetVirtualScreen(xRes,yRes:integer);
Set up a virtual screen with higher 'resolution' than the one given
by the initialized CRT mode.
procedure SetVisualScreen (x,y:integer);
Determine the visible part of the vitual screen: